﻿using System;
using DocumentFormat.OpenXml.Wordprocessing;

namespace OpenXmlEasy.Word
{
    /// <summary>
    /// 页面方向
    /// </summary>
    public partial class WordEasy
    {

        /// <summary>
        /// 横向
        /// </summary>
        public void SetPageLandscape()
        {
            var paragraph1 = new Paragraph
            {
                RsidParagraphAddition = Guid.NewGuid().ToString(),
                RsidParagraphProperties = Guid.NewGuid().ToString(),
                RsidRunAdditionDefault = Guid.NewGuid().ToString()
            };

            var paragraphProperties1 = new ParagraphProperties();

            var sectionProperties1 = new SectionProperties { RsidR = Guid.NewGuid().ToString(), RsidSect = Guid.NewGuid().ToString() };
            var pageSize1 = new PageSize { Width = 16838U, Height = 11906U };
            var pageMargin1 = new PageMargin { Top = 1440, Right = 1080U, Bottom = 1440, Left = 1080U, Header = 851U, Footer = 992U, Gutter = 0U };
            var columns1 = new Columns { Space = "425" };
            var docGrid1 = new DocGrid { Type = DocGridValues.Lines, LinePitch = 312 };

            sectionProperties1.AppendChild(pageSize1);
            sectionProperties1.AppendChild(pageMargin1);
            sectionProperties1.AppendChild(columns1);
            sectionProperties1.AppendChild(docGrid1);

            paragraphProperties1.AppendChild(sectionProperties1);

            paragraph1.AppendChild(paragraphProperties1);

            _body.AppendChild(paragraph1);
        }

        /// <summary>
        /// 纵向
        /// </summary>
        public void SetPagePortrait()
        {
            var paragraph1 = new Paragraph
            {
                RsidParagraphAddition = Guid.NewGuid().ToString(),
                RsidParagraphProperties = Guid.NewGuid().ToString(),
                RsidRunAdditionDefault = Guid.NewGuid().ToString()
            };

            var paragraphProperties1 = new ParagraphProperties();

            var sectionProperties1 = new SectionProperties { RsidR = Guid.NewGuid().ToString(), RsidSect = Guid.NewGuid().ToString() };
            var pageSize1 = new PageSize { Width = 11906U, Height = 16838U };
            var pageMargin1 = new PageMargin { Top = 1440, Right = 1080U, Bottom = 1440, Left = 1080U, Header = 851U, Footer = 992U, Gutter = 0U };
            var columns1 = new Columns { Space = "425" };
            var docGrid1 = new DocGrid { Type = DocGridValues.Lines, LinePitch = 312 };

            sectionProperties1.AppendChild(pageSize1);
            sectionProperties1.AppendChild(pageMargin1);
            sectionProperties1.AppendChild(columns1);
            sectionProperties1.AppendChild(docGrid1);

            paragraphProperties1.AppendChild(sectionProperties1);

            paragraph1.AppendChild(paragraphProperties1);

            _body.AppendChild(paragraph1);
        }

    }
}
